package com.xiaomaoguai.guava.predicate;

import java.util.List;

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.Lists;

/**
 * @Description :
 * @FileName: MainTest.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年11月2日 上午10:35:02
 * @Version:V1.00
 */
public class MainTest {

	public static void main(String[] args) {
		ImmutableMultiset<Person> multiset = testPredict();

		for (Person person : multiset) {
			System.out.println(person);
		}
	}

	public static ImmutableMultiset<Person> testPredict() {

		List<Person> persons = Lists.newArrayList(new Person(1, 0, "zhanssg"), new Person(1, 1, "huang"),
				new Person(1, 1, "zhang"));

		return ImmutableMultiset.copyOf(Collections2.filter(persons, new Predicate<Person>() {

			@Override
			public boolean apply(Person input) {
				return input.getSex() == 1;
			}
		}));
	}

}
